<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" omit-xml-declaration="yes" />

  <xsl:template match="/rss/channel">
    
    <script type="text/javascript">
      var firstItem = true;
      var insertBr = false;
      var currentYear = 0;
      
      function writeYear(input){
        if (currentYear != input){
          if (firstItem != true){
            document.write("<br/><br/>");
          }
          document.write("<h3>" + input + "</h3><br />");
          currentYear = input;
          firstItem = false;
        }
      }
    </script>
    
    <xsl:for-each select="item">
     <xsl:sort select="sortDate" order="descending"/>
      <script type="text/javascript">
        writeYear(<xsl:value-of select="substring(sortDate, 0,5)"/>);
      </script>
      <div style="padding-bottom:10px;">
        <p>
          <script>
            document.write(dateFormat("<xsl:value-of select="pubDate" />", "dd mmmm yyyy"))
          </script>
          <br />
          <xsl:value-of select="title" />
          <a target="_blank">
            <xsl:attribute name="href">
              <xsl:value-of select="link" />
            </xsl:attribute>
            <xsl:attribute name="class">
              <xsl:text>inLineLink</xsl:text>
            </xsl:attribute>
            ...more
          </a>
        </p>
      </div>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>